﻿using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Medicalsystem.MCP.FormDesigner.Common;

namespace Medicalsystem.MCP.FormDesigner.Ctl
{
    /// <summary>
    /// 捏手控件-用于改变控件Size
    /// </summary>
    [ToolboxItem(false)]
    public partial class ctl_UISizeDot : DevExpress.XtraEditors.XtraUserControl
    {
        public ctl_UISizeDot()
        {
            InitializeComponent();

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            this.TabStop = false;
        }

        private DotType _type = DotType.WestNorth;
        private bool _isFocus = false;
        private Pen pen = new Pen(Color.Black);

        public Color BorderColor
        {
            get
            {
                return pen.Color;
            }
            set
            {
                pen.Color = value;
            }
        }

        /// <summary>
        /// 类型
        /// </summary>
        public DotType Type
        {
            get { return _type; }
            set
            {
                _type = value;
            }
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            // TODO: 在此处添加自定义绘制代码

            if (_isFocus)
            {
                pe.Graphics.DrawLine(pen, new Point(1, 0), new Point(this.Width - 2, 0));
                pe.Graphics.DrawLine(pen, new Point(this.Width - 1, 1), new Point(this.Width - 1, this.Height - 2));
                pe.Graphics.DrawLine(pen, new Point(this.Width - 2, this.Height - 1), new Point(1, this.Height - 1));
                pe.Graphics.DrawLine(pen, new Point(0, this.Height - 2), new Point(0, 1));
            }
            else
            {
                pe.Graphics.DrawRectangle(pen, 0, 0, this.Width - 1, this.Height - 1);
            }

            // 调用基类 OnPaint
            base.OnPaint(pe);
        }
    }
}